package ru.urfc.portal.model.accounting;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import ru.urfc.portal.model.SpectrObjectWithContragent;
import ru.urfc.portal.ui.client.Constants;

@Table(name = "portal_invoicefactures")
@Entity
@XmlRootElement(name = Constants.INVOICE_FACTURE)
public class InvoiceFacture extends SpectrObjectWithContragent implements BalanceOperation {
	private String number;
	@Column(name = "subject")
	private String name;
	@Temporal(TemporalType.DATE)
	private Date date;
	@Column(scale = 2, precision = 16)
	private BigDecimal amount;
	
	public InvoiceFacture() {
	}

	public InvoiceFacture(Contragent contragent, String number, String name,
			Date date, BigDecimal amount) {
		super(contragent);
		this.number = number;
		this.name = name;
		this.date = date;
		this.amount = amount;
	}

	@XmlElement
	public BigDecimal getAmount() {
		return amount;
	}
	
	@XmlElement
	public String getNumber() {
		return number;
	}
	
	@XmlTransient
	@Override
	public BigDecimal getAmountWithSign() {
		return amount.negate();
	}

	@XmlElement
	@Override
	public Date getDate() {
		return date;
	}

	@XmlElement
	@Override
	public String getName() {
		return name;
	}
	
}
